package one.bugu.zookeeper.rpc.framework.client;

import one.bugu.zookeeper.rpc.framework.annotations.RpcClient;
import one.bugu.zookeeper.rpc.framework.client.zookeeper.IRegisterCenterInvoker;
import one.bugu.zookeeper.rpc.framework.util.SpringContextUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: LangK
 * Created Date 2019/2/11
 * Time: 14:31
 * Description: 服务注册
 */
public class ClientRegister {

    private Logger logger = LoggerFactory.getLogger(ClientRegister.class);

    private IRegisterCenterInvoker registerCenterInvoker;

    public ClientRegister(IRegisterCenterInvoker registerCenterInvoker) {
        this.registerCenterInvoker = registerCenterInvoker;
        getServerInfoZK();
    }

    public void getServerInfoZK() {
        Map<String, Object> beanWithAnnotations = SpringContextUtil.getApplicationContext().getBeansWithAnnotation(RpcClient.class);
        if (beanWithAnnotations == null || beanWithAnnotations.isEmpty()) {
            return;
        }
        this.registerCenterInvoker.initProviderMap();

    }

}
